//
// OpenArrow Utility Library
// Copyright (c) 2006
// by OpenArrow Software ( http://www.openarrow.com )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using System.Collections.Generic;
using System.Text;
using OpenArrow.Properties;

namespace OpenArrow.Reporting
{
    /// <summary>
    /// Represents the Progress Reporter that does nothing.
    /// <seealso cref="OpenArrow.Reporting.IProgressReporter"/>
    /// </summary>
    /// <remarks>
    /// This reporter is designed to be used when the caller of a method that accepts a progress reporter is not concerned with recieving progress reports.
    /// </remarks>
    public class NullProgressReporter : IProgressReporter
    {
        #region IProgressReporter Members

        /// <summary>
        /// Starts a new task with the specified number of work items
        /// <seealso cref="OpenArrow.Reporting.IProgressReporter.StartTask(string, int)"/>
        /// </summary>
        /// <param name="taskName">The name of the task</param>
        /// <param name="workItems">The number of work items in the task</param>
        /// <returns>
        /// An <see cref="System.IDisposable"/> object that calls <see cref="OpenArrow.Reporting.IProgressReporter.EndTask"/> on disposal.
        /// Designed to be used in a C# using statement
        /// </returns>
        /// <example>
        /// <code>
        /// IProgressReporter rpt = // Create a progress reporter
        /// using(rpt.StartTask("Some Task", 4)) 
        /// {
        ///     // Do Work
        /// } // EndTask called here
        /// </code>
        /// </example>
        /// <exception cref="ArgumentException"><paramref name="taskName"/> is <see langword="null"/> or <see cref="String.Empty"/></exception>
        public IDisposable StartTask(string taskName, int workItems)
        {
            if (String.IsNullOrEmpty(taskName))
                throw new ArgumentException(String.Format(Resources.Exception_ArgIsNullOrEmpty, "taskName"), "taskName");

            return StartTask(taskName);
        }

        /// <summary>
        /// Starts a new task with an unknown number of work items
        /// <seealso cref="OpenArrow.Reporting.IProgressReporter.StartTask(string)"/>
        /// </summary>
        /// <param name="taskName">The name of the task</param>
        /// <returns>
        /// An <see cref="System.IDisposable"/> object that calls <see cref="OpenArrow.Reporting.IProgressReporter.EndTask"/> on disposal.
        /// Designed to be used in a C# using statement
        /// </returns>
        /// <example>
        /// <code>
        /// IProgressReporter rpt = // Create a progress reporter
        /// using(rpt.StartTask("Some Task", 4)) 
        /// {
        ///     // Do Work
        /// } // EndTask called here
        /// </code>
        /// </example>
        /// <exception cref="ArgumentException"><paramref name="taskName"/> is <see langword="null"/> or <see cref="String.Empty"/></exception>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object)")]
        public IDisposable StartTask(string taskName)
        {
            if (String.IsNullOrEmpty(taskName))
                throw new ArgumentException(String.Format(Resources.Exception_ArgIsNullOrEmpty, "taskName"), "taskName");

            return new ProgressReporterToken(this);
        }

        /// <summary>
        /// Ends the current task and returns to the task that this one was started from
        /// <seealso cref="OpenArrow.Reporting.IProgressReporter.EndTask"/>
        /// </summary>
        public void EndTask()
        {
            return;
        }

        /// <summary>
        /// Performs a unit of work on the current task
        /// <seealso cref="OpenArrow.Reporting.IProgressReporter.DoWork"/>
        /// </summary>
        public void DoWork()
        {
            return;
        }

        #endregion
    }

}
